<!DOCTYPE html>
<html lang="en">
	<head>
		<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> -->
		<meta charset="utf-8" />
		<title>实验室设备管理系统</title>
		
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<link rel="shortcut icon" href="plugins/images/favicon.ico" type="image/x-icon" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="plugins/ace/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="plugins/ace/assets/css/font-awesome.css" />
		<link rel="stylesheet" href="plugins/ace/assets/css/jquery-ui.css" />
		
		<link rel="stylesheet" href="plugins/ace/assets/css/ui.jqgrid.css" />   

		<!-- text fonts -->
		<link rel="stylesheet" href="plugins/ace/assets/css/ace-fonts.css" />

		<!-- 文件上传 -->
		<link rel="stylesheet" href="plugins/ace/assets/css/dropzone.css" />
		<link rel="stylesheet" href="plugins/ace/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />

		<!-- ace styles -->
		<link rel="stylesheet" href="plugins/ace/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />

	<link rel="stylesheet" href="plugins/layer/skin/layer.css">
	<link rel="stylesheet" href="plugins/layer/skin/layer.ext.css">
	<!-- //zTree_v3 -->
	<link rel="stylesheet" href="plugins/zTree_v3/css/metroStyle/metroStyle.css" type="text/css">
	<link rel="stylesheet" href="plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
	
	<link rel="stylesheet" href="plugins/ace/assets/css/ace.onpage-help.css" />
	<!-- 日期 -->
	<link rel="stylesheet" href="plugins/layui-master/build/css/layui.css"  media="all">
	<script src="plugins/layui-master/build/layui.js" charset="utf-8"></script>
	<!-- 分页 -->
	<link rel="stylesheet" href="plugins/laypage/skin/laypage.css" type="text/css">
	<script src="js/jquery-1.9.1.js"></script>
		<!-- validate验证 -->
	<script src="plugins/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
	<!-- 中文信息包 -->
	<script src="plugins/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
	<script src="plugins/laypage/laypage.js"></script>
	<style type="text/css">
	.ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
	</style>
	
		<script src="plugins/ace/assets/js/ace-extra.js"></script>
		<script src="plugins/echart/echarts-all.js" type="text/javascript"></script>
		
		<style type="text/css">
		.ztree span {
			font-size: 15px;
			height: 2em;
		}
		.ztree li {
			margin-top: 5px;
		}
		</style>
		
	<!-- 引入layer -->
	<link rel="stylesheet" href="layui/css/layui.css" type="text/css">
	<script src="layui/layui.js" type="text/javascript"></script>
	</head>

	<body class="no-skin">
		<!-- #section:basics/navbar.layout -->
		<div id="navbar" class="navbar navbar-default">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>

			<div class="navbar-container" id="navbar-container">
				<button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler" data-target="#sidebar">
					<span class="sr-only"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				 
				<!-- /section:basics/sidebar.mobile.toggle -->
				<div class="navbar-header pull-left">
					<a href="" class="navbar-brand" style="height: 45px;padding-top: 1px;">
						<small >
							<img alt="LOGO" style="height: 43px;" src="plugins/images/minlogo.png">
							实验室设备管理系统
						</small>
					</a>

				</div>

				<div class="navbar-buttons navbar-header pull-right" role="navigation">
					<ul class="nav ace-nav">
						<li class="light-blue">
							<a data-toggle="dropdown" href="#" class="dropdown-toggle">
								<img class="nav-user-photo" src="plugins/ace/assets/avatars/user.jpg"  />
								<span class="user-info">
									<small>欢迎您</small>
									<span id="userNameTitle"></span>
								</span>

								<i class="ace-icon fa fa-caret-down"></i>
							</a>

							<ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
								<li>
									<a href="javascript:personInfo()">
										<i class="ace-icon fa fa-user"></i>
										个人资料
									</a>
								</li>
								<li>	
									<a href="javascript:updatePassword()">
										<i class="ace-icon fa fa-cog"></i>
										修改密码
									</a>
								</li>
								<li class="divider"></li>

								<li>
									<a id="signout">
										<i class="ace-icon fa fa-power-off"></i>
										退出
									</a>
								</li>
							</ul>
						</li>

						<!-- /section:basics/navbar.user_menu -->
					</ul>
				</div>
				<!-- /section:basics/navbar.dropdown -->
			</div><!-- /.navbar-container -->
		</div>
		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>
			<div id="sidebar" class="sidebar responsive">
				<script type="text/javascript">
					try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
				</script>

				<ul class="nav nav-list" id="topTree">
					<li class="active">
						<a href="#">
							<i class="menu-icon fa fa-tachometer"></i>
							<span class="menu-text"> 首页 </span>
						</a>
					</li>
				</ul><!-- /.nav-list -->

				<!-- #section:basics/sidebar.layout.minimize -->
				<div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
					<i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
				</div>

				<!-- /section:basics/sidebar.layout.minimize -->
				<script type="text/javascript">
					try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
				</script>
			</div>
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div id="main-content-inner">
				</div>
			</div><!-- /.main-content -->
			<div class="footer">
				<div class="footer-inner">
					<!-- #section:basics/footer -->
					<div class="footer-content">
						<span class="bigger-120">
							Copyright © 2017 ZZU. All Rights Reserved.
						</span>
						&nbsp; &nbsp;
					</div>
				</div>
			</div>

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div>

		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='plugins/ace/assets/js/jquery.mobile.custom.js'>"+"<"+"/script>");
		</script>

		<script src="plugins/ace/assets/js/bootstrap.js"></script>
		<script src="plugins/ace/assets/js/jquery-ui.js"></script>
		<script src="plugins/ace/assets/js/jquery.ui.touch-punch.js"></script>
		
		<!-- page specific plugin scripts -->
		<script src="plugins/ace/assets/js/dataTables/jquery.dataTables.js"></script>
		<script src="plugins/ace/assets/js/dataTables/jquery.dataTables.bootstrap.js"></script>
		<script src="plugins/ace/assets/js/dataTables/extensions/TableTools/js/dataTables.tableTools.js"></script>
		<script src="plugins/ace/assets/js/dataTables/extensions/ColVis/js/dataTables.colVis.js"></script>

		<!-- 文件上传 -->
		<script src="plugins/ace/assets/js/dropzone.js"></script>
		<!-- ace scripts -->
		<script src="plugins/ace/assets/js/ace/elements.scroller.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.colorpicker.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.fileinput.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.typeahead.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.wysiwyg.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.spinner.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.treeview.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.wizard.js"></script>
		<script src="plugins/ace/assets/js/ace/elements.aside.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.ajax-content.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.touch-drag.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.sidebar.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.sidebar-scroll-1.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.submenu-hover.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.widget-box.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.settings.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.settings-rtl.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.settings-skin.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.widget-on-reload.js"></script>
		<script src="plugins/ace/assets/js/ace/ace.searchbox-autocomplete.js"></script>
		
		<script src="plugins/ace/assets/js/jqGrid/jquery.jqGrid.src.js"></script>    <!-- ~~ -->
		<script src="plugins/ace/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>  <!-- ~~ -->
		
		<script src="plugins/ace/assets/js/jquery.autosize.js"></script>

		<!-- the following scripts are used in demo only for onpage help and you don't need them -->
		
	    <script src="plugins/layer/layer.js"></script> 
	    <script src="plugins/layer/extend/layer.ext.js"></script> 
		<!-- <script type="text/javascript" src="plugins/layer/extend/layer.ext.js"></script>   -->
		<script type="text/javascript" src="plugins/artDialog/jquery.artDialog.js?skin=twitter"></script>
		<script type="text/javascript" src="plugins/artDialog/plugins/iframeTools.js"></script>
		
		<script type="text/javascript" src="plugins/echart/echarts.js"></script>
		<script type="text/javascript" src="plugins/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
		<script type="text/javascript" src="plugins/zTree_v3/js/jquery.ztree.excheck-3.5.js"></script>
		<script type="text/javascript" src="plugins/zTree_v3/js/jquery.ztree.exedit-3.5.js"></script>
		
		<script type="text/javascript" src="plugins/My97DatePicker/WdatePicker.js"></script>
		
		<script src="js/jquery-form.js" type="text/javascript"></script>
		<script src="js/jquery.myLayout.js"></script>
		<script src="js/jquery.myTree.js"></script>
	<div hidden="hidden" id="updatePwd">
		<div class="col-xs-12">&nbsp;</div>
		<div class="col-xs-12">
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">原密码</label>
				<div class="col-sm-10" style="float: left">
					<input id="old_pwd" type="password" class="form-control"
						placeholder="请输入旧密码" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">新密码</label>
				<div class="col-sm-10" style="float: left">
					<input id="new_pwd" type="password" class="form-control"
						placeholder="请输入新密码" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">新密码</label>
				<div class="col-sm-10" style="float: left">
					<input id="new_pwd1" type="password" class="form-control"
						placeholder="请再次输入新密码" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
		</div>
	</div>
	<div hidden="hidden" id="userInfo">
		<div class="col-xs-12">&nbsp;</div>
		<input id="userId" type="text" hidden="hidden" />
		<div class="col-xs-12">
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">用户名</label>
				<div class="col-sm-10" style="float: left">
					<input id="userName" type="text" class="form-control" placeholder="请输入用户名" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">邮箱</label>
				<div class="col-sm-10" style="float: left">
					<input id="userEmail" type="text" class="form-control" placeholder="请输入邮箱" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">手机号</label>
				<div class="col-sm-10" style="float: left">
					<input id="userPhone" type="text" class="form-control" placeholder="请输入手机号" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
		</div>
	</div>
<!-- 初始化加载菜单项 -->
<script type="text/javascript">
	var $url = window.location.hash;
	$.get("act/getMenuList", function(resp) {
		$("#topTree").toTree(resp.content, "0");
		$.onHeaderClick();
	});
	
	/* $url = 'polls/listByPageAndPoliceId'; */
	$.updateByUrl($url.substr(1));
	window.onhashchange = function() {
		$.updateByUrl(window.location.hash.substr(1));
	};
</script>
<!-- 用户信息 -->
<script type="text/javascript">
loadUserInfo();
/**
 * 加载用户信息
 */
function loadUserInfo(){
	$.get("getUserInfo",function(resp){
		$("#userId").html(resp.id);
		$("#userNameTitle").html(resp.name);
		$("#userName").val(resp.name);
		$("#userPhone").val(resp.phone);
		$("#userEmail").val(resp.email);
	});
};
	
/**
 * 修改密码
 */
function updatePassword(){
	userModel = layer.open({
		type: 1,
		shade: [0.5],
		title: '修改密码', //不显示标题
		area: ['30%', '250px'],
		content: $('#updatePwd'), //捕获的元素
		btn: [ '确认','取消'],
		yes: function(index, layero){ //或者使用btn1
			var old = $("#old_pwd").val();
			var str1 = $("#new_pwd").val();
			var str2 = $("#new_pwd1").val();
			if(old==""||str1==""){
				 layer.msg("密码不能为空!");
				 return;
			}else if(str1!=str2){
				 layer.msg("两次输入的密码不同,请重新输入!");
				 return;
			}
			
			$.post("updatePwd",{"oldPwd":old,"newPwd":str1},function(resp){ // 提交信息修改密码
				  if(resp=='success'){
				    	layer.msg("密码修改成功，请重新登陆!",{time:2500});
						layer.close(index);
						
						setTimeout("window.location.href='logout'",3000); // 延迟3秒跳转页面 
				   }else if(resp=='oldPwdError'){
					  	layer.msg("原密码错误，请重新输入！");
					    return;
				   }else{
					   layer.msg("修改失败!");
					   layer.close(index);
				   }
			});
		},
		cancel: function(index){
			layer.close(index);
			layer.msg("取消");
		},
	});
};		
		
/**
 * 修改个人信息
 */
function personInfo() {
	userModel = layer.open({
		type : 1,
		shade : [ 0.5 ],
		title : '个人信息',
		area : [ '30%', '300px' ],
		content : $('#userInfo'), //捕获的元素
		btn : [ '确认', '取消' ],
		yes : function(index, layero) {
			var name = $("#userName").val();
			var phone = $("#userPhone").val();
			var email = $("#userEmail").val();
			
			if(name==""||phone==""||email==""){
				layer.msg("请将信息填写完整！");
				return;
			}else if(isExist()){ // 验证邮箱、手机号是否重复
				return;
			}
			
			$.post("updateUserInfo", {"name":name,"phone":phone,"email":email}, function(resp) {
				if (resp == 'success') {
					layer.msg("修改成功");
					loadUserInfo();
				} else {
					layer.msg("修改失败");
				}
			});
			layer.close(index);
		},
		cancel : function(index) {
			layer.close(index);
			layer.msg("取消");
		},
	});
}

/**
 * 验证手机号、邮箱是否已绑定其他账号
 */
function isExist(){
	var isExist = false;  // 定义返回值变量

	var url = "user/isExist"; // 定义请求地址
	
	var	data = {
		"email" : $("#userEmail").val(),
		"phone" : $("#userPhone").val(),
		"userId" : $("#userId").val(),
	};
	
	$.ajax({ type:"POST", url : url, async : false, data : data,
		 success : function(resp){
			 if(resp!=0){ // 存在重复
				isExist = true;  // 将查询的结果赋给返回值
				if(resp==1){
					layer.msg("该邮箱已经绑定其他账号，请更换邮箱");
				}else if(resp==2){
					layer.msg("该手机号已经绑定其他账号，请更换手机号");
				}else{
					layer.msg("该邮箱和手机号已绑定其他账号，请更换邮箱和手机号");
				}
			}
		} 
	});
	return isExist;
}
</script>
		
<script type="text/javascript">
/**
 * 退出系统
 */
	$("#signout").click(function(){
		layer.confirm('确定是否退出？', {
		  btn: ['确定','取消'] 
		}, function(){
			window.location.href="logout";
		}, function(){
			 layer.msg("已取消");
		});
	});
</script>
	</body>
</html>
